package com.example.express.utlis;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.express.R;

public class DialogUtil {

    public static void show(Context context,String str,Listener listener) {
        Dialog bottomDialog = new Dialog(context, R.style.BottomDialog);
        View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_content_normal, null);
        bottomDialog.setContentView(contentView);
        bottomDialog.getWindow().setGravity(Gravity.CENTER);
        bottomDialog.getWindow().setWindowAnimations(R.style.BottomDialog_Animation);
        bottomDialog.show();
        TextView tvTitle = contentView.findViewById(R.id.tv_title);
        TextView tvTo = contentView.findViewById(R.id.tv_to);
        TextView tvCancel = contentView.findViewById(R.id.tv_cancel);
        tvTitle.setText("拨号："+str);
        tvTo.setOnClickListener(v -> {
            listener.item(str);
            bottomDialog.cancel();
        });
        tvCancel.setOnClickListener(v -> {
            bottomDialog.cancel();
        });
    }

    public interface Listener{
        void item(String phone);
    }
}
